package com.mgm.country.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mgm.constant.APICode;
import com.mgm.constant.GobalConstant;
import com.mgm.country.service.CountryService;
import com.mgm.dao.CountryMapper;
import com.mgm.pojo.Country;
import com.mgm.result.IMessage;

@Service
public class CountryServiceImpl implements CountryService {
	
	@Autowired
	private CountryMapper countryMapper;

	@Override
	public List<Country> findAll() {
		return countryMapper.selectAll();
	}
	
	@Override
	public List<String> selectShort() {
		return countryMapper.selectShort();
	}

	@Override
	public IMessage selectByAbbr(String[] abbr) {
		IMessage msg = IMessage.success();
		for (int i = 0; i < abbr.length; i++) {
			Country country = countryMapper.selectByAbbr(abbr[i]);
			if (country == null) {
				return msg.error("Not found country!");
			}
		}
		return msg;
	}
	

}
